package com.exercise.AndroidCamera;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.os.Build;

public class FrameBaseActivity extends FragmentActivity {
    private static Typeface mTypeface = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_frame_base);
	}

	@Override
	public void setContentView(int layoutResID) {
		super.setContentView(layoutResID);
        if (mTypeface == null) {
            mTypeface = Typeface.createFromAsset(this.getAssets(), "fonts/whitechok.ttf"); 
        }
        setGlobalFont(getWindow().getDecorView());
	}
	 
	private void setGlobalFont(View view) {
	        if (view != null) {
	            if(view instanceof ViewGroup){
	                ViewGroup vg = (ViewGroup)view;
	                int vgCnt = vg.getChildCount();
	                for(int i=0; i < vgCnt; i++){
	                    View v = vg.getChildAt(i);
	                    if(v instanceof TextView){
	                        ((TextView) v).setTypeface(mTypeface);
	                    }
	                    setGlobalFont(v);
	                }
	            }
	        }
	    }
	
	}
